// pages/newindex/newindex.js
const util = require('../../utils/util.js')
const auth = require('../../utils/auth.js');
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    liveFlag:false,
    bookingFlag:true,
    centerFlag:false,
    imgUrls: [
'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
        'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
        'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
    ],
    indicatorDots: true,
    autoplay: true,
    interval: 5000,
    duration: 1000,
    indicatorColor:'#104166',
    indicatorActiveColor:'#4393d0',
    liveList:[
      {  src:'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
      name:'一号望远镜',
      disabled:false
      },
      {       src:'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
      name:'二号望远镜',
      disabled: false
      },
      {
        src: 'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
        name: '三号望远镜',
        disabled: false
      },
     {
       src: 'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
       name: '四号望远镜',
       disabled: true
     }
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  // 轮播图片接口
  var that=this;
  
      util.ajax({
        url: '/api/wx-app/carousel',
        data: {
            
        },
        method:'POST',
        header: {
            'content-type': 'application/json' // 默认值
        },
        success: function(res) {
           console.log(res)
        }
      });
      //望远镜的请求接口
      util.ajax({
        url: '/api/wx-app/glass_list',
        data: {
            
        },
        method:'POST',
        header: {
            'content-type': 'application/json' // 默认值
        },
        success: function(res) {
        	console.log('望远镜')
           console.log(res)
        }
      });
  },
  _changeBar: function(e) {
    // tabber 切换
    console.log(e)
    var that = this ;
    var _type = e.detail.type;
    switch (_type) {
      case 'booking':
        that.setData({
          liveFlag: false,
          bookingFlag: true,
          centerFlag: false,
        });
        wx.redirectTo({
          url: "../../pages/newindex/newindex"
        });
        break;
      case 'live':
        that.setData({
          liveFlag: true,
          bookingFlag: false,
          centerFlag: false,
        });
        wx.redirectTo({
          url: "../../pages/live-list/live-list"
        });
        break;
      case 'center':
        that.setData({
          liveFlag: false,
          bookingFlag: false,
          centerFlag: true,
        });
        wx.redirectTo({
          url: "../../pages/my-center/my-center"
        })
        break;
    }
  },

  turnTo:function(){
    wx.navigateTo({
      url: '../../pages/immediately-order/immediately-order'
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})